﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XMLSpreadGear.Core;

namespace XMLSpreadGear.Templates
{
    public class Comment:BaseElement
    {
        private string sAuthor;

        public string Author
        {
            get { return sAuthor; }
            set { sAuthor = value; }
        }
        private bool? bShowAlways;

        public bool? ShowAlways
        {
            get { return bShowAlways; }
            set { bShowAlways = value; }
        }
        private Data dData;

        public Data Data
        {
            get { return dData; }
            set { dData = value; }
        }

        public Comment(string strlocalname, Data data)
            : base(strlocalname)
        {
            dData = data;
        }

        public Comment(string strlocalname, string author, bool showAlways, Data data)
            : this(strlocalname,data)
        {
            sAuthor = author;
            bShowAlways = showAlways;
            
        }


        internal protected override IDictionary<string, string> RegisterElements()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("Data", this.Data.ToString());
            return dic;
        }

        internal protected override IDictionary<string, string> RegisterAttributes()
        {
            IDictionary<string, string> dic = new Dictionary<string, string>();
            if(!string.IsNullOrEmpty(this.Author))
                dic.Add("Author", this.Author);

            if(this.ShowAlways != null)
                dic.Add("ShowAlways", this.ShowAlways.ToByte().ToString());

            return dic;
        }

        protected override void SetDefaults()
        {
            return;
        }

        internal override string GetAttributeNamespace()
        {
            return Contstants.SpredsheetAttributePrefix;
        }

        internal override string GetAttributeNamespaceURI()
        {
            return Contstants.SpredsheetAttributeNamespace;
        }
    }
}
